<?php
class Model_LibraryAcl extends Zend_Acl {
    public function __construct() {
        $this->addRole(new Zend_Acl_Role('guests'));
        $this->addRole(new Zend_Acl_Role('users'), 'guests');
        $this->addRole(new Zend_Acl_Role('admins'), 'users');

		$this->add(new Zend_Acl_Resource('admin'))
			 ->add(new Zend_Acl_Resource('admin:authentication'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:nguoidung'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:giaovien'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:khoahoc'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:diemthi'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:lophoc'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:error'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:hinhthucthi'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:loaidaotao'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:hocvien'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:index'), 'admin')
			 ->add(new Zend_Acl_Resource('admin:tintuc'), 'admin');
			 
		$this->add(new Zend_Acl_Resource('default'))
			 ->add(new Zend_Acl_Resource('default:authentication'), 'default')
			 ->add(new Zend_Acl_Resource('default:search'), 'default')
			 ->add(new Zend_Acl_Resource('default:index'), 'default')
			 ->add(new Zend_Acl_Resource('default:hocvien'), 'default')
			 ->add(new Zend_Acl_Resource('default:error'), 'default')
			 ->add(new Zend_Acl_Resource('default:users'), 'default');
		
		$this->allow('guests', 'default:authentication', 'login');
		$this->allow('guests', 'admin:authentication', 'login');
		$this->allow('guests', 'default:error', 'error');
		$this->allow('guests', 'admin:nguoidung', 'validateform');
		$this->allow('guests', 'default:users', 'register');
		$this->allow('guests', 'default:hocvien', 'register');
		$this->allow('guests', 'default:search', 'index');
		$this->allow('guests', 'default:index', array('index', 'view-cart','add-item', 'remove','detail','category','category-product','category2','category2-product'));
		$this->deny('users', 'default:users', 'register');
		$this->deny('users', 'default:authentication', 'login');
		$this->allow('users', 'default:authentication', 'logout');
		$this->allow('users','default:index', 'order');
		
		$this->allow('admins', 'admin:hocvien', array('index', 'them', 'capnhat', 'xoa','xemdiem','xemtkb','nhan'));
		$this->allow('admins', 'admin:diemthi', array('index', 'danhsachdiem', 'nhapdiem','xemdiem'));
		$this->allow('admins', 'admin:hinhthucthi', array('index', 'them', 'capnhat', 'xoa'));
		$this->allow('admins', 'admin:loaidaotao', array('index', 'them', 'capnhat', 'xoa'));
		$this->allow('admins', 'admin:nguoidung', array('index', 'them', 'capnhat', 'xoa'));
		$this->allow('admins', 'admin:giaovien', array('index', 'them', 'capnhat', 'xoa','validateform'));
		$this->allow('admins', 'admin:index', array('index', 'them', 'capnhat', 'xoa','thongke'));
		$this->allow('admins', 'admin:khoahoc', array('index', 'them', 'capnhat', 'xoa','danhsach','validateform'));
		$this->allow('admins', 'admin:lophoc', array('index', 'them', 'capnhat', 'xoa','danhsach'));
		$this->allow('admins', 'admin:tintuc', array('index','chudelist','themcd', 'them', 'capnhat', 'xoa','danhsach'));
		$this->allow('admins', 'admin:error', array('error'));
		$this->deny('admins', 'admin:authentication', 'login');
		$this->allow('admins', 'admin:authentication', 'logout');
    }
}
